package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.Detailsinfo;
import com.ysd.entity.ProductclassifiCationTable;
import com.ysd.util.DBManager;

public class lia {
	public List<Detailsinfo> Detailsinfo(){
		List<Detailsinfo> list = new ArrayList<Detailsinfo>();
		Connection conn = DBManager.grtConnection();
		Statement st = null;
		ResultSet rs = null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from Detailsinfo order by rand() limit 4");
			while(rs.next()) {
				String newsTitle = rs.getString("newsTitle");
				int consultationId = rs.getInt("consultationId");
				int newsId = rs.getInt("newsId");
				String newsDetails = rs.getString("newsDetails");
				String nt = rs.getString("nt");
				Detailsinfo Detailsinfo = new Detailsinfo(newsId, newsTitle, newsDetails, consultationId, nt);
				list.add(Detailsinfo);
			}
			return list;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	} 
}
